$(function(){
	var grid = ViewLoader.grids["doc-grid"];
	grid.doAdd = function(){
		if(grid.addForm.valid()){
			grid.addForm.ajaxSubmit({
				type: "post",
				dataType: "json",
				url:grid.editPath,
				success:function(result){
					grid.addPanel.modal("hide");
					grid.reload();
				}
			});
		};
		return false;
	};
});

$("#addModal form input[name='importType']").change(function(){
	
	var selectVal = $("#addModal form input[name='importType']:checked").val();
	
	//选择文档  
	if("0" == selectVal){
		$("#addModal form input[name='name']").attr("disabled","disabled");
		$("#addModal form input[name='queryIndex']").attr("disabled","disabled");
		$("#addModal form input[name='userIdIndex']").attr("disabled","disabled");
		$("#addModal form select[name='docId']").removeAttr("disabled");
		
	//新建文档
	}else{
		$("#addModal form input[name='name']").removeAttr("disabled");
		$("#addModal form input[name='queryIndex']").removeAttr("disabled");
		$("#addModal form input[name='userIdIndex']").removeAttr("disabled");
		$("#addModal form select[name='docId']").attr("disabled","disabled");
	}
});
